package com.eva.framework.common.exception;

import com.eva.framework.common.constants.ResponseStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务异常对象
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BusinessException extends RuntimeException {

    private Integer code;

    private Object errorData;

    public BusinessException(Integer code, String message) {
        this(code, message, null, null);
    }

    public BusinessException(Integer code, String message, Object errorData) {
        this(code, message, errorData, null);
    }

    public BusinessException(ResponseStatus status) {
        this(status.getCode(), status.getMessage(), null, null);
    }

    public BusinessException(ResponseStatus status, String message) {
        this(status.getCode(), message, null, null);
    }

    public BusinessException(ResponseStatus status, Object errorData) {
        this(status.getCode(), status.getMessage(), errorData, null);
    }

    public BusinessException(ResponseStatus status, Object errorData, Throwable e) {
        this(status.getCode(), status.getMessage(), errorData, e);
    }

    public BusinessException(Integer code, String message, Object errorData, Throwable e) {
        super(message, e);
        this.code = code;
        this.errorData = errorData;
    }
}
